import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from "../views/home/Home.vue"
import QRCode from "../views/QRCode/QRCode.vue"
import Integral from "../views/Integral/Integral.vue"
import Help from "../views/Help/Help.vue"
import FeedbackDetails from "../views/FeedbackDetails/FeedbackDetails.vue"
import Feedback from "../views/Feedback/Feedback.vue"
import ForgetPwd from "../views/ForgetPwd/ForgetPwd.vue"
import Vote from "../views/Vote/Vote.vue"
import Found from "../views/Found/found.vue"
import NPSmouth from '../views/NPSmouth/NPSmouth.vue'
import Mouth from '../views/mouth/mouth.vue'
import sign from '../views/sign/sign.vue'
import NPSlistDetails from '../views/NPSlistDetails/NPSlistDetails.vue'
import Login from '../views/login/Login.vue'
import Register from '../views/login/register.vue'

import ForgetPassword from '../views/login/forgetPassword.vue'
import Follow from '../views/follow/Follow.vue'
import Comments from '../views/comments/Comments.vue'
import Activity from '../views/activity/Activity.vue'
import Shenzhen from '../views/shenzhen/Shenzhen.vue'
import Focus from '../views/focus/Focus.vue'
import Journal from '../views/journal/Journal.vue'
import MagazineList from '../views/magazineList/MagazineList.vue'
import ListContent from '../views/listContent/ListContent.vue'
import Create from "../views/Create/create.vue"
import QualityList from "../views/QualityList/qualityList.vue"
import Food from "../views/Food/food.vue"
import QualityArchives from "../views/QualityArchives/qualityArchives.vue"
import QualityArchivestu from "../views/QualityArchives/qualityArchivestu.vue"
import SuperiorProduct from "../views/QualityArchives/superiorProduct.vue"
import EditData from '../views/EditData/EditData.vue'
import Member from '../views/Member/Member.vue'
import NPSlist from "../views/NPSlist/NPSlist.vue"
import NPShelp from "../views/NPShelp/NPShelp.vue"
import NPSscore1 from "../views/NPSscore1/NPSscore1.vue"
import NPSscore2 from "../views/NPSscore2/NPSscore2.vue"
import redbag from "../views/redbag/redbag.vue"
import invitation from "../views/invitation/invitation.vue"
import voucher from "../views/voucher/voucher.vue"
import Shops from "../views/shops/Shops.vue"
import Gouwuche from "../views/shops/gouwuche.vue"
import Jiesuan from "../views/shops/jiesuan.vue"
import Zhuangtai from '../views/shops/zhuangtai.vue'
Vue.use(VueRouter)
const routes = [{
        path: '/',

        redirect: "/Home"
    },
    {
        path: '/Home',

        component: Home
    },
    {
        path: "/food",

        component: Food
    },
    {
        path: "/qualityArchives",

        component: QualityArchives
    },
    {
        path: "/qualityArchivestu",

        component: QualityArchivestu
    },
    {
        path: "/superiorProduct",

        component: SuperiorProduct
    },
    {
        path: '/login',

        component: Login
    },
    {
        path: '/zhuangtai',

        component: Zhuangtai
    },
    {
        path: "/jiesuan",

        component: Jiesuan
    },
    {
        path: '/register',

        component: Register
    },
    {
        path: '/forgetPassword',

        component: ForgetPassword
    },

    {
        path: '/follow',
        // name: Follow,
        component: Follow
    },
    {
        path: '/comments',
        // name: Comments,
        component: Comments
    },
    {
        path: '/activity',
        // name: Activity,
        component: Activity
    },
    {
        path: '/shenzhen',
        // name: Shenzhen,
        component: Shenzhen
    },
    {
        path: '/focus',
        // name: Focus,
        component: Focus
    },
    {
        path: '/journal',
        // name: Journal,
        component: Journal
    },
    {
        path: '/magazineList',
        // name: MagazineList,
        component: MagazineList
    },
    {
        path: '/listContent',
        // name: ListContent,
        component: ListContent
    },
    {
        path: "/found",
        // name: Found,
        component: Found
    },
    {
        path: "/QRCode",
        // name: QRCode,
        component: QRCode
    },
    {
        path: "/Integral",
        // name: Integral,
        component: Integral
    },
    {
        path: "/Help",
        // name: Help,
        component: Help
    },
    {
        path: "/FeedbackDetails",
        // name: FeedbackDetails,
        component: FeedbackDetails
    },
    {
        path: "/Feedback",
        // name: Feedback,
        component: Feedback
    },
    {
        path: "/ForgetPwd",
        // name: ForgetPwd,
        component: ForgetPwd
    },
    {
        path: "/Vote",
        // name: Vote,
        component: Vote
    },
    {
        path: '/NPSmouth',
        // name: NPSmouth,
        component: NPSmouth
    },
    {
        path: '/mouth',
        // name: Mouth,
        component: Mouth
    },
    {
        path: '/sign',
        // name: sign,
        component: sign
    },
    {
        path: '/NPSlistDetails',
        // name: NPSlistDetails,
        component: NPSlistDetails
    },
    {
        path: "/create",
        // name: Create,
        component: Create
    },
    {
        path: "/qualityList",
        // name: QualityList,/
        component: QualityList
    },
    {
        path: '/EditData',
        // name: EditData,
        component: EditData
    },
    {
        path: '/Member',
        // name: Member,
        component: Member
    }, {
        path: '/NPSscore1',
        // name: NPSscore1,
        component: NPSscore1
    },
    {
        path: '/NPSscore2',
        // name: NPSscore2,
        component: NPSscore2
    }, {
        path: '/NPShelp',
        // name: NPShelp,
        component: NPShelp
    }, {
        path: '/NPSlist',
        // name: NPSlist,
        component: NPSlist
    }, {
        path: '/redbag',
        // name: redbag,/
        component: redbag
    }, {
        path: '/invitation',
        // name: invitation,/
        component: invitation
    }, {
        path: '/voucher',
        // name: voucher,
        component: voucher
    },
    {
        path: '/shops',
        // props: true,
        // name: Shops,
        component: Shops
    },
    {
        path: '/gouwuche',
        // name: Gouwuche,
        component: Gouwuche
    },
]
const router = new VueRouter({
    routes
})
router.beforeEach((to, from, next) => {
    // 判断用户是否登录 ？ 如果用户没有用登录 那么用户去登录页面
    // 如果用户本身就是登录了 直接放行
    // 如果用户登录了 ，那么可以去任何想去的地方 （放行）
    let flag = window.localStorage.getItem("myToken") || false;
    if (flag) {
        next()
    } else if (to.path !== '/login') {
        next({ path: "/login" });
    } else {
        next()
    }
})
export default router